import request from '@/utils/request'

// 地址

// 地址对象删除
export function delAddrData (params) {
  var data = fromData(params)
  return request({
    url: '/addr/del_addr',
    method: 'post',
    data
  })
}

// 地址对象查看
export function getAddrArray (params) {
  var data = fromData(params)
  return request({
    url: '/addr/getAddrArray',
    method: 'post',
    data
  })
}

// 增加地址对象信息
export function addAddrInfo (params) {
  var data = fromData(params)
  return request({
    url: '/addr/addAddrInfo',
    method: 'post',
    data
  })
}

// 编辑地址对象信息
export function editAddrInfo (params) {
  var data = fromData(params)
  return request({
    url: '/addr/editAddrInfo',
    method: 'post',
    data
  })
}

// 获取地址对象信息
export function getAddrInfo (params) {
  var data = fromData(params)
  return request({
    url: '/addr/getAddrInfo',
    method: 'post',
    data
  })
}

// 转换为资产对象信息
export function shiftAssetObject (params) {
  var data = fromData(params)
  return request({
    url: '/addr/shiftAssetObject',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
